package com.tss.utils;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;


import net.sf.json.JSONObject;

public class JsonUtil {
	public static <T> JSONObject transformToJson(T t){
		Map<String,String> map = new HashMap<String,String>();
		try {
			Field[] fields = t.getClass().getFields();
			for(Field field:fields){
				Object o = field.get(t);
				map.put(field.getName(),(String)o);
			}
		} catch (Exception e) {
		}
		JSONObject json =JSONObject.fromObject(map);
		return json;
	}
}
